//package com.stxx.stiot2.event;
//
//import com.alibaba.fastjson2.JSON;
//import com.stxx.stiot2.constants.Topics;
//import com.stxx.stiot2.event.dto.P2tMsg;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.dromara.mica.mqtt.server.solon.MqttServerTemplate;
//import org.eclipse.paho.client.mqttv3.MqttException;
//import org.noear.solon.annotation.Component;
//import org.noear.solon.annotation.Inject;
//
//import java.lang.reflect.Array;
//import java.nio.charset.StandardCharsets;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.Map;
//@Slf4j
//
//@Component
//public class P2tService {
//
////    @Inject
////    private MqttServer mqttServer;
//    @Inject
//    private MqttServerTemplate server;
//
//    public void read(String gatewayCode, String terminalCode,String[] message){
//        P2tMsg p2tMsg = new P2tMsg();
//        p2tMsg.setProperties(String.join(",",message));
//        //p2tMsg.getProperties().put("fields",message);
//        server.publishAll(Topics.topic(gatewayCode,terminalCode,Topics.P2t.get_properties),JSON.toJSONString(p2tMsg).getBytes(StandardCharsets.UTF_8));
//    }
//    public void write(String gatewayCode,String terminalCode,Map<String,Object> message){
//        P2tMsg p2tMsg = new P2tMsg();
//        p2tMsg.setProperties(JSON.toJSONString(message));
//        server.publishAll(Topics.topic(gatewayCode,terminalCode,Topics.P2t.set_properties), JSON.toJSONString(p2tMsg).getBytes(StandardCharsets.UTF_8));
//
//    }
//}
